<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        
        <meta name="author" content="Mr.Wang">
        <link rel="canonical" href="http://www.mapgoo.net/llgl/">
        <link rel="shortcut icon" href="../img/favicon.ico">
        <title>流量管理 - 智能麦联</title>
        <link href="../css/bootstrap-custom.min.css" rel="stylesheet">
        <link href="../css/font-awesome-4.5.0.css" rel="stylesheet">
        <link href="../css/base.css" rel="stylesheet">
        <link rel="stylesheet" href="../css/highlight.css">
        <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
            <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->
	
	<script src="../js/jquery-1.10.2.min.js"></script>
        <script src="../js/bootstrap-3.0.3.min.js"></script>
        <script src="../js/highlight.pack.js"></script> 
    </head>

    <body>

        <div class="navbar navbar-default navbar-fixed-top" role="navigation">
    <div class="container">

        <!-- Collapsed navigation -->
        <div class="navbar-header">
            <!-- Expander button -->
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="..">智能麦联</a>
        </div>

        <!-- Expanded navigation -->
        <div class="navbar-collapse collapse">
                <!-- Main navigation -->
                <ul class="nav navbar-nav">
                    <li >
                        <a href="..">对接协议</a>
                    </li>
                    <li >
                        <a href="../acc/">远程唤醒</a>
                    </li>
                    <li class="active">
                        <a href="./">流量管理</a>
                    </li>
                    <li >
                        <a href="../whitelist/">白名单应用</a>
                    </li>
                    <li >
                        <a href="../link/">联系</a>
                    </li>
                </ul>

            <ul class="nav navbar-nav navbar-right">
                <li>
                    <a href="#" data-toggle="modal" data-target="#mkdocs_search_modal">
                        <i class="fa fa-search"></i> Search
                    </a>
                </li>
                    <li >
                        <a rel="next" href="../acc/">
                            <i class="fa fa-arrow-left"></i> Previous
                        </a>
                    </li>
                    <li >
                        <a rel="prev" href="../whitelist/">
                            Next <i class="fa fa-arrow-right"></i>
                        </a>
                    </li>
            </ul>
        </div>
    </div>
</div>

        <div class="container">
                <div class="col-md-3"><div class="bs-sidebar hidden-print affix well" role="complementary">
    <ul class="nav bs-sidenav">
        <li class="main active"><a href="#_1">背景</a></li>
        <li class="main "><a href="#_2">协议约定</a></li>
    </ul>
</div></div>
                <div class="col-md-9" role="main">

<h2 id="_1">背景</h2>
<blockquote>
<p>第三方系统(智能车载)中内置<code>流量管理APK(以下简称:APK)</code>，由APK提供与流量卡相关的信息，如：剩余流量、已用流量、总流量、剩余天数、提示状态。通过这些信息，系统可以实现自行展现效果(如:YunOS的卡片界面)，因此约定以下广播协议：</p>
</blockquote>
<h2 id="_2">协议约定</h2>
<blockquote>
<p>消息名: intent.action.mapgoo.simtool.info </p>
<p>消息说明：第三方应用请求流量信息</p>
<p>消息流向: 第三方应用 → APK</p>
</blockquote>
<pre><code class="java">// 传入整型的0或1，0标识拿本地缓存的，1标识从网络获取最新的
Intent intent = new Intent(&quot;intent.action.mapgoo.simtool.info&quot;);
intent.putExtra(&quot;getCache&quot;, 0);  //取值范围:0或1，0表示缓存信息，1表示获取最新 
sendBroadCast(intent);
</code></pre>

<hr />
<blockquote>
<p>消息名: intent.action.mapgoo.simtool.info.triffic.v2</p>
<p>消息说明：APK发送流量信息给第三方应用</p>
<p>消息流向: APK → 第三方应用</p>
<p>特别说明：</p>
</blockquote>
<ul>
<li>流量卡的套餐约定中：每月流量是否清零，决定着广播协议输出内容不同；</li>
<li>当card_type返回0时，其它字段的值不起作用。</li>
</ul>
<blockquote>
<p>流量值单位：统一为MB</p>
</blockquote>
<pre><code class="java">// 流量卡套餐：联通卡、本月清零

Intent intent = new Intent(&quot;intent.action.mapgoo.simtool.info.triffic.v2&quot;);

intent.putExtra(&quot;card_type&quot;,1);  //流量卡类型, 0-非本系统卡 1-联通卡 2-移动卡 3-电信卡

intent.putExtra(&quot;is_reset&quot;,1);        // 当月流量卡是否清零 0-不清零 1-清零

//如果是清零卡，则返回下列信息
intent.putExtra(&quot;zero_card_total_usage&quot;,138924.1); //清零卡套餐内总流量,数据类型:double;
intent.putExtra(&quot;zero_card_surplusUsage&quot;,321.2); //清零卡套餐剩余总流量,数据类型:double;

intent.putExtra(&quot;total_usage&quot;, 1380.0);    //  本月总流量，数据类型：double
intent.putExtra(&quot;doneUsage&quot;, 256.0);       //  本月已用流量，数据类型：double
intent.putExtra(&quot;surplusUsage&quot;, 1024.0);   //  本月剩余流量，数据类型：double
intent.putExtra(&quot;surplus_period&quot;, 1254);   //  本月剩余天数 ，数据类型：int，单位：天

intent.putExtra(&quot;tips&quot;,1);            // 提示状态，0-不用提示，1-需要提示

sendBroadcast(intent);
</code></pre>

<pre><code class="java">// 流量卡套餐：联通卡、不清零
Intent intent = new Intent(&quot;intent.action.mapgoo.simtool.info.triffic.v2&quot;);

intent.putExtra(&quot;card_type&quot;,1);  //流量卡类型, 0-非本系统卡 1-联通卡 2-移动卡 3-电信卡
intent.putExtra(&quot;is_reset&quot;,0);        // 当月流量卡是否清零 0-不清零 1-清零

intent.putExtra(&quot;total_usage&quot;, 1380.0);    //  总流量，数据类型：double
intent.putExtra(&quot;doneUsage&quot;, 256.0);       //  已用流量，数据类型：double
intent.putExtra(&quot;surplusUsage&quot;, 1024.0);   //  剩余流量，数据类型：double
intent.putExtra(&quot;surplus_period&quot;, 1254);   //  剩余天数 ，数据类型：int，单位：天

intent.putExtra(&quot;tips&quot;,1);            // 提示状态，0-不用提示，1-需要提示

sendBroadcast(intent);
</code></pre>

<pre><code class="java">// 流量卡套餐：移动卡、不清零
Intent intent = new Intent(&quot;intent.action.mapgoo.simtool.info.triffic.v2&quot;);

intent.putExtra(&quot;card_type&quot;,2);  //流量卡类型, 0-非本系统卡 1-联通卡 2-移动卡 3-电信卡
intent.putExtra(&quot;is_reset&quot;,0);        // 当月流量卡是否清零 0-不清零 1-清零

intent.putExtra(&quot;total_usage&quot;, 1380.0);    //  总流量，数据类型：double
intent.putExtra(&quot;doneUsage&quot;, 256.0);       //  已用流量，数据类型：double
intent.putExtra(&quot;surplusUsage&quot;, 1024.0);   //  剩余流量，数据类型：double
intent.putExtra(&quot;surplus_period&quot;, 1254);   //  剩余天数 ，数据类型：int，单位：天

intent.putExtra(&quot;tips&quot;,1);            // 提示状态，0-不用提示，1-需要提示

sendBroadcast(intent);
</code></pre>

<hr />
<blockquote>
<p>消息名: intent.action.mapgoo.simtool.start</p>
<p>消息说明：第三方应用打开APK</p>
<p>消息流向: 第三方应用 → APK</p>
</blockquote>
<pre><code class="java">Intent intent = new Intent(&quot;intent.action.mapgoo.simtool.start&quot;);
intent.putExtra(&quot;tips&quot;, 1);   // 提示状态，0-不用提示，1-需要提示
sendBroadcast(intent);
</code></pre>

<hr />
<blockquote>
<p>消息名: intent.action.mapgoo.simtool.info.triffic （<code>老广播协议，v4.3.2版本后已废弃</code>)</p>
<p>消息说明：APK发送流量信息给第三方应用</p>
<p>消息流向: APK → 第三方应用</p>
</blockquote>
<pre><code class="java">// 流量值的单位统一为：MB
Intent intent = new Intent(&quot;intent.action.mapgoo.simtool.info.triffic&quot;);
intent.putStringExtra(&quot;surplusUsage&quot;, 1024);   // 剩余流量，数据类型：double
intent.putStringExtra(&quot;doneUsage&quot;, 256);   // 已用流量，数据类型：double
sendBroadCast(intent);
</code></pre></div>
        </div>

        <footer class="col-md-12">
            <hr>
                <p>Copyright (c) 2016 by MapGoo</p>
            <p>Documentation built with <a href="http://www.mkdocs.org/">MkDocs</a>.</p>
        </footer>
        <script>var base_url = '..';</script>
        <script data-main="../mkdocs/js/search.js" src="../mkdocs/js/require.js"></script>
        <script src="../js/base.js"></script><div class="modal" id="mkdocs_search_modal" tabindex="-1" role="dialog" aria-labelledby="Search Modal" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="exampleModalLabel">Search</h4>
            </div>
            <div class="modal-body">
                <p>
                    From here you can search these documents. Enter
                    your search terms below.
                </p>
                <form role="form">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Search..." id="mkdocs-search-query">
                    </div>
                </form>
                <div id="mkdocs-search-results"></div>
            </div>
            <div class="modal-footer">
            </div>
        </div>
    </div>
</div>

    </body>
</html>
